package com.liu.jpamysql.mapper;

import com.liu.jpamysql.model.Students;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @Author QS.Liu
 * @date 2020/7/23/23:30
 * 定义Dao接口继承JpaRepository:
 * JpaRepository接口有简单的增删改查方法，通过继承可以使用相应的方法
 * Student 实体类 Integer 主键
 */
public interface StudentDao extends JpaRepository<Students,Integer> {
    Students findStuById(int id);
    @Query(name = "findByName",nativeQuery = true,value = "select * from t_stu where name = :name")
    List<Students> findByName(@Param("name")String name);
}

